package springcloud.config;

import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
//编码方式实现路由网关
//当访问地址为http://localhost:9527时会自动转发到地址:http://www.baidu.com
@Configuration
public class GatewayConfig {
    @Bean
    public RouteLocator customRouteLocator(RouteLocatorBuilder routeLocatorBuilder){
        RouteLocatorBuilder.Builder routes = routeLocatorBuilder.routes();
        routes.route("path_route3",
                r -> r.path("/payment/discovery").uri("http://localhost:8081")).build();
        return routes.build();
    }
}
